package com.product.android.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.common.android.ui.gif.GifCacheManager;
import com.common.android.utils.StackManager;
import com.flurry.android.FlurryAgent;
import com.product.android.business.config.Configuration;

public class BaseFragmentActivity extends FragmentActivity{


	 protected static long preTime=0;
	
	@Override
	 protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    _onCreate(savedInstanceState);
	    StackManager.putFragmentActivity(this);
	 }
	
	protected boolean _onCreate(Bundle savedInstanceState){
		restoreInstance(savedInstanceState);
		return true;
	}
   
   public void  restoreInstance(Bundle savedInstanceState){
//		CommonUtils.restoreCurrentUser();
   }
	
	protected void goTo(Class<?> cls){
		Intent intent = new Intent(BaseFragmentActivity.this,cls);
		this.startActivity(intent);
	}
	
	public void goTo(Class<?> cls,Bundle bundle){
		Intent intent = new Intent(BaseFragmentActivity.this,cls);
		intent.putExtras(bundle);
		this.startActivity(intent);
	}
	
	
	protected void toActivity(Class<?> cls,boolean flag){
		Intent intent = new Intent();
		intent.setClass(this, cls);			
		startActivity(intent);		
		if(flag){
			finish();
		}
	}
	
	protected void toActivity(Class<?> cls,Bundle bundle){
		Intent intent = new Intent();
		intent.putExtras(bundle);
		intent.setClass(this, cls);			
		startActivity(intent);		
	}
	
	
	
	protected void initComponent(){}
	protected void initComponentValue(){}
	protected void initEvent(){}
	
	@Override
	protected void onStart() {
		super.onStart();
		FlurryAgent.setReportLocation(false);
		FlurryAgent.onStartSession(this,Configuration.FLURRYKEY );
	}
	
	@Override
	public void onResume(){
		super.onResume();
		GifCacheManager.INSTANCE.deActive();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
	}
	
	@Override
	protected void onStop(){
		super.onStop();
		FlurryAgent.onEndSession(this);
	}

	@Override
	protected void onDestroy() {
//		if(m_dialog!=null){
//			m_dialog.dismiss();
//		}
		StackManager.pullFragmentActivity(this);
		super.onDestroy();
	}
	
}
